package com.tjetc.view.manage;

import com.tjetc.proxy.ClientProxy;
import com.tjetc.service.IdCardService;
import com.tjetc.vo.Result;

import java.util.Scanner;

public class IdCardView {
    Scanner sc = new Scanner(System.in);
    static IdCardService idCardService = ClientProxy.getProxyInstance(IdCardService.class);
    public void start() {
        while(true){
            try{
                System.out.println("1.根据新生儿儿的id添加身份证");
                System.out.println("2.删除新生儿的身份证");
                System.out.println("提示修改新生儿的信息才会修改身份证,无法自主修改");
                System.out.println("0.返回上一级");
                int i= sc.nextInt();
                switch (i){
                    case 1:
                        System.out.println("请输入新生儿的id");
                        int id = sc.nextInt();
                        Result result = idCardService.setIdCardById(id);
                        System.out.println(result.getMsg());
                        if (result.getCode()==200){
                            System.out.println(result.getData());
                        }
                        break;
                    case 2:
                        System.out.println("请输入新生儿的id");
                        int id1 = sc.nextInt();
                        int i1 = idCardService.deleteIdCardById(id1);
                        if (i1==1){
                            System.out.println("删除成功");
                        }else {
                            System.out.println("删除失败");
                        }
                        break;
                    case 0:
                        return;
                }
            }catch (Exception e){
                System.out.println("输入错误");
                sc.nextLine();
            }
        }
    }
}
